]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Fixes for Calendar widget
authorOwen W. Taylor <otaylor@fishsoup.net>
Thu, 1 Oct 2009 20:14:50 +0000 (16:14 -0400)
committerOwen W. Taylor <otaylor@fishsoup.net>
Thu, 1 Oct 2009 20:48:24 +0000 (16:48 -0400)
Miscellaneous fixes from review:

- Distribute calendar.js and the interactive test
- Make the pointless protection against leap seconds actually work
  by starting in the middle of the day so that forward/back always
  move a day.
- Use a variable instead of an inline '8' to know where to start
  when removing old day actors.
- Remove a stray comment from the test

https://bugzilla.gnome.org/show_bug.cgi?id=596432

js/ui/Makefile.am
js/ui/calendar.js
js/ui/panel.js
tests/Makefile.am
tests/interactive/calendar.js

index 4f6490cac5cb2e8b8d2f740b4125499a6f298e22..d4eccc3cd5df3ca5d4526dcc201df4b738116b55 100644 (file)
@@ -5,6 +5,7 @@ dist_jsui_DATA =                \
        appDisplay.js           \
        appIcon.js              \
        button.js               \
+       calendar.js             \
        chrome.js               \
        dash.js                 \
        dnd.js                  \
index de7f4023a3a7d698d6e992dc1140c4bb639b14d1..d8b380ae797c20925e18ec2844e3a1fc301d675f 100644 (file)
@@ -79,6 +79,7 @@ Calendar.prototype = {
         // them in the right cell in the table. It doesn't matter if we add them in order
         let iter = new Date(this.date);
         iter.setSeconds(0); // Leap second protection. Hah!
+        iter.setHours(12);
         for (let i = 0; i < 7; i++) {
             this.actor.add(new St.Label({ text: iter.toLocaleFormat("%a") }),
                            { row: 1,
@@ -87,6 +88,9 @@ Calendar.prototype = {
             iter.setTime(iter.getTime() + MSECS_IN_DAY);
         }
 
+        // All the children after this are days, and get removed when we update the calendar
+        this._firstDayIndex = this.actor.get_children().length;
+
         this._update();
     },
 
@@ -132,17 +136,18 @@ Calendar.prototype = {
     },
 
     _update: function() {
-        this._dateLabel.text = this.date.toLocaleFormat("%B %Y");
+        this._dateLabel.text = this.date.toLocaleFormat(this._headerFormat);
 
         // Remove everything but the topBox and the weekday labels
         let children = this.actor.get_children();
-        for (let i = 8; i < children.length; i++)
+        for (let i = this._firstDayIndex; i < children.length; i++)
             children[i].destroy();
 
         // Start at the beginning of the week before the start of the month
         let iter = new Date(this.date);
         iter.setDate(1);
         iter.setSeconds(0);
+        iter.setHours(12);
         iter.setTime(iter.getTime() - (iter.getDay() - this._weekStart) * MSECS_IN_DAY);
 
         let now = new Date();
index 92a1bf8046e56dbed1da3c796a9f083831790740..58803b30a634d644c0a2547a9015e64ab2bee18b 100644 (file)
@@ -518,6 +518,10 @@ CalendarPopup.prototype = {
         this.calendar = new Calendar.Calendar();
         this.actor.add(this.calendar.actor);
 
+        // Directly adding the actor to Main.chrome.actor is a hack to
+        // work around the fact that there is no way to add an actor that
+        // affects the input region but not the shape.
+        // See: https://bugzilla.gnome.org/show_bug.cgi?id=597044
         Main.chrome.actor.add_actor(this.actor);
         Main.chrome.addInputRegionActor(this.actor);
         this.actor.y = (panelActor.y + panelActor.height - this.actor.height);
index 43bfbb5222017e2e14fd791ec8f08f645b0aa319..49a15bba3f51df6655d6871de508e51fad362eb0 100644 (file)
@@ -3,7 +3,8 @@ EXTRA_DIST = run-test.sh.in
 
 TEST_JS =                                      \
        testcommon/ui.js                        \
-       interactive/box-layout.js
+       interactive/box-layout.js               \
+       interactive/calendar.js
 EXTRA_DIST += $(TEST_JS)
 
 TEST_MISC =                                    \
index 9336c95c982f47ba5446f9451c71eaa72f039ead..f8f50b97d329da2a1c3d0b487c615a2854f1deaf 100644 (file)
@@ -4,11 +4,9 @@ const Clutter = imports.gi.Clutter;
 const Lang = imports.lang;
 const St = imports.gi.St;
 
-const Calendar =imports.ui.calendar;
+const Calendar = imports.ui.calendar;
 const UI = imports.testcommon.ui;
 
-const Gettext_gtk20 = imports.gettext.domain('gtk20');
-
 UI.init();
 let stage = Clutter.Stage.get_default();
 stage.width = stage.height = 400;